473,461 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to make control visible/invisible on mouseover.

I have a form with a bunch of image buttons. When the user moves the mouse
over a button, I want to do two things: 1. change the Imagebutton's picture,
and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible property
by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript, and
then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!
Nov 19 '05 #1
6 14664
Just not that the ASP.net generates client-side ids that don't necessarily
match the id of the control. For example, if you could have two user
controls on the same page both containing a textbox named "username".
ASP.Net can't output two <input type="text" tags with the same id (ie,
"username"). Hence it must dynamically generate an id (the name of the
textbox appended to the user control). This might be what's happening.

Or it could simply be that it's getElementById instead of GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className =
'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
I have a form with a bunch of image buttons. When the user moves the mouse
over a button, I want to do two things: 1. change the Imagebutton's
picture, and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible property
by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return
false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript, and
then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!

Nov 19 '05 #2
Just not that the ASP.net generates client-side ids that don't necessarily
match the id of the control. For example, if you could have two user
controls on the same page both containing a textbox named "username".
ASP.Net can't output two <input type="text" tags with the same id (ie,
"username"). Hence it must dynamically generate an id (the name of the
textbox appended to the user control). This might be what's happening.

Or it could simply be that it's getElementById instead of GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className =
'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
I have a form with a bunch of image buttons. When the user moves the mouse
over a button, I want to do two things: 1. change the Imagebutton's
picture, and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible property
by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return
false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript, and
then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!

Nov 19 '05 #3
Hi Karl,

Thanks for the feedback and suggestions.
I tried that script too, but just got a script error when I rolled the mouse
over the button.

I haven't gotten any other suggestions. I wonder if it's possible to write
the routine I want in VB script instead of java? Is it any easier to access
controls on your web page with VB script?

Thanks,
---Selden
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uV*************@TK2MSFTNGP14.phx.gbl...
Just not that the ASP.net generates client-side ids that don't necessarily
match the id of the control. For example, if you could have two user
controls on the same page both containing a textbox named "username".
ASP.Net can't output two <input type="text" tags with the same id (ie,
"username"). Hence it must dynamically generate an id (the name of the
textbox appended to the user control). This might be what's happening.

Or it could simply be that it's getElementById instead of GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className =
'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
I have a form with a bunch of image buttons. When the user moves the
mouse over a button, I want to do two things: 1. change the Imagebutton's
picture, and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible
property by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return
false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript,
and then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!


Nov 19 '05 #4
Not really. Perhaps if you showed us what you have thus far?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:e%****************@TK2MSFTNGP10.phx.gbl...
Hi Karl,

Thanks for the feedback and suggestions.
I tried that script too, but just got a script error when I rolled the
mouse over the button.

I haven't gotten any other suggestions. I wonder if it's possible to
write the routine I want in VB script instead of java? Is it any easier
to access controls on your web page with VB script?

Thanks,
---Selden
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uV*************@TK2MSFTNGP14.phx.gbl...
Just not that the ASP.net generates client-side ids that don't
necessarily match the id of the control. For example, if you could have
two user controls on the same page both containing a textbox named
"username". ASP.Net can't output two <input type="text" tags with the
same id (ie, "username"). Hence it must dynamically generate an id (the
name of the textbox appended to the user control). This might be what's
happening.

Or it could simply be that it's getElementById instead of GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className =
'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
I have a form with a bunch of image buttons. When the user moves the
mouse over a button, I want to do two things: 1. change the Imagebutton's
picture, and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible
property by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return
false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript,
and then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!



Nov 19 '05 #5
Thanks, good suggestion!

Here's what I've tried, what worked and what didn't:

First, there is a panel on the page, "Panel1" if I set it's CssClass to
"vs1" it is visible. If I set it to "vs2" it is invisible. I've confirmed
this several times.

this worked:
sPic3 = "family/purchase/images/portrait_navs/" & sTitle &
"3.gif"
iBut.Attributes.Add("onMouseOver", "this.src='" & sPic3 & "'")

This gave me a script error: (tried with and without the return false):
script = "document.GetElementByID('panel1').className =
'vs1';return false;"
iBut.Attributes.Add("onMouseOver", script)

This also gave me a script error:
script = "document.getElementById('" & Panel1.ClientID &
"').className = 'vs1'; "
iBut.Attributes.Add("onMouseOver", script)

As an aside, setting the panel visible/invisible is a fall back. What I
would REALLY want to do is set the text of a label to any one of 15
different values, depending on what button the mouse is rolling over. Also
I would want to set the image for an image control at the same time. But if
I can't do that, then I thought I would pre-set up 15 different panels with
the values already filled in, and just make one visible at the rollover.

---Selden


"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2***************@TK2MSFTNGP15.phx.gbl...
Not really. Perhaps if you showed us what you have thus far?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:e%****************@TK2MSFTNGP10.phx.gbl...
Hi Karl,

Thanks for the feedback and suggestions.
I tried that script too, but just got a script error when I rolled the
mouse over the button.

I haven't gotten any other suggestions. I wonder if it's possible to
write the routine I want in VB script instead of java? Is it any easier
to access controls on your web page with VB script?

Thanks,
---Selden
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uV*************@TK2MSFTNGP14.phx.gbl...
Just not that the ASP.net generates client-side ids that don't
necessarily match the id of the control. For example, if you could have
two user controls on the same page both containing a textbox named
"username". ASP.Net can't output two <input type="text" tags with the
same id (ie, "username"). Hence it must dynamically generate an id (the
name of the textbox appended to the user control). This might be
what's happening.

Or it could simply be that it's getElementById instead of GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className =
'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
I have a form with a bunch of image buttons. When the user moves the
mouse over a button, I want to do two things: 1. change the
Imagebutton's picture, and 2. make another control visible.

I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
'somepicture.jpg')
and that works fine.

I've tried some java script to change the other control's visible
property by changing is className, but that doesn't seem to work

script = "document.GetElementByID('panel1').className = 'vs1';return
false;"
iBut.Attributes.Add("onMouseOver", script)

but that gives me a script error on the page when I mouseover the image
button. (I've tried it with and without the return false)

So how do I change the visibility property of a control in javascript,
and then, how do I combine two steps into one onMouseOver?

Thanks!
---Selden <--- java newbie!



Nov 19 '05 #6
I also found another project where something like this is working, so I
copied that script but it wasn't working for me.

Here's what I found, in the aspx page of the other project

onclick='document.forms[0].btnTest.click();'

It looks like this was clicking a button, on the click event of another
control.

So I tried this: (image button ibPkgB is an image button, that, when you
click it, does what I want to happen on a mouse over...)

iBut.Attributes.Add("onMouseOver", "document.forms[0].ibPkgB.click();")

Gave me an error, so I tried:
iBut.Attributes.Add("onMouseOver", "document.ibPkgB.click();")

I checked, and ibPkgB's "ID" and "ClientID" properties are both "ibPkgB" so
it didn't seem worthwhile adding that to the script.

So that's all I've tried so far...

---Selden

"Selden McCabe" <se*****@msn.com> wrote in message
news:uI**************@TK2MSFTNGP10.phx.gbl...
Thanks, good suggestion!

Here's what I've tried, what worked and what didn't:

First, there is a panel on the page, "Panel1" if I set it's CssClass to
"vs1" it is visible. If I set it to "vs2" it is invisible. I've
confirmed this several times.

this worked:
sPic3 = "family/purchase/images/portrait_navs/" & sTitle &
"3.gif"
iBut.Attributes.Add("onMouseOver", "this.src='" & sPic3 & "'")

This gave me a script error: (tried with and without the return false):
script = "document.GetElementByID('panel1').className =
'vs1';return false;"
iBut.Attributes.Add("onMouseOver", script)

This also gave me a script error:
script = "document.getElementById('" & Panel1.ClientID &
"').className = 'vs1'; "
iBut.Attributes.Add("onMouseOver", script)

As an aside, setting the panel visible/invisible is a fall back. What I
would REALLY want to do is set the text of a label to any one of 15
different values, depending on what button the mouse is rolling over.
Also I would want to set the image for an image control at the same time.
But if I can't do that, then I thought I would pre-set up 15 different
panels with the values already filled in, and just make one visible at the
rollover.

---Selden


"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2***************@TK2MSFTNGP15.phx.gbl...
Not really. Perhaps if you showed us what you have thus far?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:e%****************@TK2MSFTNGP10.phx.gbl...
Hi Karl,

Thanks for the feedback and suggestions.
I tried that script too, but just got a script error when I rolled the
mouse over the button.

I haven't gotten any other suggestions. I wonder if it's possible to
write the routine I want in VB script instead of java? Is it any easier
to access controls on your web page with VB script?

Thanks,
---Selden
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uV*************@TK2MSFTNGP14.phx.gbl...
Just not that the ASP.net generates client-side ids that don't
necessarily match the id of the control. For example, if you could have
two user controls on the same page both containing a textbox named
"username". ASP.Net can't output two <input type="text" tags with the
same id (ie, "username"). Hence it must dynamically generate an id
(the name of the textbox appended to the user control). This might be
what's happening.

Or it could simply be that it's getElementById instead of
GetElementByID

Try

script = "document.getElementById('" & panel1.ClientId & "').className
= 'vs1'; ....."

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Selden McCabe" <se*****@msn.com> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
>I have a form with a bunch of image buttons. When the user moves the
>mouse over a button, I want to do two things: 1. change the
>Imagebutton's picture, and 2. make another control visible.
>
> I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src =
> 'somepicture.jpg')
> and that works fine.
>
> I've tried some java script to change the other control's visible
> property by changing is className, but that doesn't seem to work
>
> script = "document.GetElementByID('panel1').className = 'vs1';return
> false;"
> iBut.Attributes.Add("onMouseOver", script)
>
> but that gives me a script error on the page when I mouseover the
> image button. (I've tried it with and without the return false)
>
> So how do I change the visibility property of a control in javascript,
> and then, how do I combine two steps into one onMouseOver?
>
> Thanks!
> ---Selden <--- java newbie!
>



Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PCB | last post by:
Hi all, Not sure if this is possible, but can I change the controls of a command button on a per record bases in a subform. In my case, I would like to make a command button visible only if...
3
by: Susan Bricker | last post by:
Greetings. I have three forms that are open at the same time. They are related and cascading. The first form (frmEventAdd) is the anchor. Each event can have many Trials. The second form is...
1
by: Anushya | last post by:
Hi All Is it possible to set the mailitem Visible/Invisible by setting something like flag or any other way? Now developing in .NET. Anushya
4
by: Gibs | last post by:
Hi, How can i make a label visible/invisible? I am able to do it for text box by using document.form1.TextBox1.style.visibility="hidden"; But when i am giving the same for the label, i am getting...
8
by: Roy | last post by:
What is the best way to approach this problem? I have a datagrid with an imagebutton. When one clicks the imagebutton it triggers an onClick sub which makes column 9 (a user control) visible or...
6
by: Nick Stansbury | last post by:
Hi, I have a loop running on Page_PreRender that sets a number of controls to invisible based on a set of criteria. Before I do this however, I set all of the drop down lists to be visible with...
0
by: Selden McCabe | last post by:
I have a form with a bunch of image buttons. When the user moves the mouse over a button, I want to do two things: 1. change the Imagebutton's picture, and 2. make another control visible. I'm...
1
by: SP | last post by:
Hello there, I have a DataList create as below. <asp:DataList ID="dl_Immunpsuppressive_Main" Runat="server" Width="100%"> <ItemTemplate> <table id="Immunpsuppressive_Main" width="100%"...
3
by: Joe | last post by:
I'm connecting to an Oracle database and running a query which returns data. The query can be fairly long - 2-3 minutes. I have a label set up on the form which is invisible to begin with. I...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.